package beanstao.util.type.base;

import beanstao.util.exception.technical.util.reflect.FailToCastObjectException;
import beanstao.util.reflect.Mirror;
import beanstao.util.type.Castor;

@SuppressWarnings({ "rawtypes" })
public class Enum2Number extends Castor<Enum, Number>
{

	@Override
	public Number cast(Enum src, Class<?> toType, String... args) throws FailToCastObjectException
	{
		Mirror<?> mirror = Mirror.me(Integer.class);
		Integer re = src.ordinal();
		if (mirror.canCastToDirectly(toType))
			return re;
		return Integer.parseInt(re.toString());
	}

}
